package com.itheima.edu.day23Executors;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorsDemo {
    public static void main(String[] args) throws InterruptedException {
        //通过newCachedThreadPool方法创建一个空的线程池，最多可以容纳int类型的最大值
        ExecutorService executorService = Executors.newCachedThreadPool();
        //Executors---》可以帮助我们创建线程池对象
        //ExecutorService---》可以帮助我们对线程池进行控制


        //ExecutorService executorService1 = Executors.newFixedThreadPool(10);
        //这也是创建了一个空的线程池，参数表示的是最多存储10个线程

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"正在执行");
        });

        Thread.sleep(2000);

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"正在执行");
        });

        executorService.shutdown();
    }
}
